/*
 * @(#)AbstractSearchForm.java
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */
package com.dcivision.framework.web;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;

import com.dcivision.framework.SystemParameterConstant;
import com.dcivision.framework.SystemParameterFactory;
import com.dcivision.framework.Utility;

/**
  AbstractSearchForm.java

  The superest class of the list search form object.

    @author          Rollo Chan
    @company         DCIVision Limited
    @creation date   08/07/2003
    @version         $Revision: 1.19.26.1 $
*/

public abstract class AbstractSearchForm extends org.apache.struts.validator.ValidatorForm {
  private String opMode;
  private String navMode;

  protected String pageOffset = SystemParameterFactory.getSystemParameter(SystemParameterConstant.PAGE_OFF_SET);
  protected String curStartRowNo = "1";
  protected String sortAttribute = "UPDATE_DATE";
  protected String sortOrder = "DESC";
  protected String pageViewOption = null;
  protected String returnTo = null;

  protected String basicSearchField = null;
  protected String basicSearchKeyword = null;
  protected String basicSearchType = "LIKE";

  //for pagerItemTag.
  protected Object pagerFirstItem = null;
  protected Object pagerLastItem = null;
  protected int pagerRecordCount = 0;  
  protected int pagerCurStartRowNo = 0;
  
  protected String[] basicSelectedID = null;
  private List searchableAttributeList = new java.util.ArrayList();
  
  private List wfRecordList = null;

  public AbstractSearchForm() {
    super();
    addSearchableAttribute("basicSearchKeyword");
  }
  
  /** Getter for property opMode.
   * @return Value of property opMode.
   */
  public String getOpMode() {
      return this.opMode;
  }

  /** Setter for property opMode.
   * @param opModes New value of property opMode.
   */
  public void setOpMode(String opMode) {
      this.opMode = opMode;
  }

  /** Getter for property navMode.
   * @return Value of property navMode.
   */
  public String getNavMode() {
      return this.navMode;
  }

  /** Setter for property navMode.
   * @param navModes New value of property navMode.
   */
  public void setNavMode(String navMode) {
      this.navMode = navMode;
  }

  public String getCurStartRowNo() {
    return(this.curStartRowNo);
  }

  public void setCurStartRowNo(String curStartRowNo) {
    this.curStartRowNo = curStartRowNo;
  }

  public String getPageOffset() {
    return(this.pageOffset);
  }

  public void setPageOffset(String pageOffset) {
    this.pageOffset = pageOffset;
  }

  public String getSortAttribute() {
    return(this.sortAttribute);
  }

  public void setSortAttribute(String sortAttribute) {
    this.sortAttribute = sortAttribute;
  }

  public String getSortOrder() {
    return(this.sortOrder);
  }

  public void setSortOrder(String sortOrder) {
    this.sortOrder = sortOrder;
  }

  public String getPageViewOption() {
    return(this.pageViewOption);
  }

  public void setPageViewOption(String pageViewOption) {
    this.pageViewOption = pageViewOption;
  }

  /** Getter for property returnTo.
   * @return Value of property returnTo.
   */
  public String getReturnTo() {
    return this.returnTo;
  }

  /** Setter for property returnTo.
   * @param returnTo New value of property returnTo.
   */
  public void setReturnTo(String returnTo) {
    this.returnTo = returnTo;
  }

  public String getBasicSearchField() {
    return(this.basicSearchField);
  }

  public void setBasicSearchField(String basicSearchField) {
    this.basicSearchField = basicSearchField;
  }

  public String getBasicSearchKeyword() {
    return(this.basicSearchKeyword);
  }

  public void setBasicSearchKeyword(String basicSearchKeyword) {
    this.basicSearchKeyword = basicSearchKeyword;
  }

  public String getBasicSearchType() {
    return(this.basicSearchType);
  }

  public void setBasicSearchType(String basicSearchType) {
    this.basicSearchType = basicSearchType;
  }

  public String[] getBasicSelectedID() {
    return(this.basicSelectedID);
  }

  public void setBasicSelectedID(String[] basicSelectedID) {
    this.basicSelectedID = basicSelectedID;
  }

  public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
    return null;
  }

  public void reset(ActionMapping mapping, HttpServletRequest request) {
    super.reset(mapping, request);
  }

  public boolean isSearchable() {
    return(!Utility.isEmpty(this.getBasicSearchKeyword()) && !Utility.isEmpty(this.getBasicSearchField()));
  }

  public boolean isSortable() {
    return(!Utility.isEmpty(this.getSortAttribute()) && !Utility.isEmpty(this.getSortOrder()));
  }

  public List getWfRecordList(){
    return this.wfRecordList;
  }

  public void setWfRecordList(List wfRecordList){    
    this.wfRecordList = wfRecordList;
  }     
    
  public int getPagerCurStartRowNo() {
  	return pagerCurStartRowNo;
  }
  
  public void setPagerCurStartRowNo(int pagerCurStartRowNo) {
  	this.pagerCurStartRowNo = pagerCurStartRowNo;
  }
  
  public Object getPagerFirstItem() {
  	return pagerFirstItem;
  }
  
  public void setPagerFirstItem(Object pagerFirstItem) {
  	this.pagerFirstItem = pagerFirstItem;
  }
  
  public Object getPagerLastItem() {
  	return pagerLastItem;
  }
  
  public void setPagerLastItem(Object pagerLastItem) {
  	this.pagerLastItem = pagerLastItem;
  }
  
  public int getPagerRecordCount() {
  	return pagerRecordCount;
  }
  
  public void setPagerRecordCount(int pagerRecordCount) {
  	this.pagerRecordCount = pagerRecordCount;
  }
  
  public List getSearchableAttributeList(){
    return searchableAttributeList;
  }
  
  protected void addSearchableAttribute(String attribute){    
    this.searchableAttributeList.add(attribute);
  } 
}